package com.wg.core.thread.scheduler;

import com.wg.core.lang.IDisposable;

public class PendingAction implements IDisposable {
    private final Runnable task;
    private boolean isCancelled;

    public PendingAction(Runnable task) {
        this.task = task;
        this.isCancelled = false;
    }

    @Override
    public void dispose() {
        this.isCancelled = true;
    }

    public void execute() {
        if (!this.isCancelled) {
            this.task.run();
        }
    }
}
